// okienko wyboru kontrahenta
unit Unit3;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, sqldb, db, FileUtil, LResources, Forms, Controls, Graphics,
  Dialogs, ExtCtrls, Buttons, DBGrids;

type

  { TForm3 }

  TForm3 = class(TForm)
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    ds: TDatasource;
    dbgrid: TDBGrid;
    Panel1: TPanel;
    query: TSQLQuery;
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    procedure FormShow(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
    idx     : integer;
    sql_txt : string;
    nazwa   : string;
  end;

var
  Form3: TForm3; 

implementation

{ TForm3 }

// odswiezenie zawartosci okienka
procedure TForm3.FormShow(Sender: TObject);
begin
  if form3.query.Active then form3.query.Close;

  form3.query.SQL.Clear;
  form3.query.SQL.Add(sql_txt);
  form3.query.Open;
end;

procedure TForm3.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  idx:=form3.query.FieldByName('idx').AsInteger;
  nazwa:=form3.query.FieldByName('nazwa').AsString;
  form3.query.Close;
end;

initialization
  {$I unit3.lrs}

end.

